<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <%@include file="/WEB-INF/common/hplus-css.jsp"%>
</head>
<body class="gray-bg">
     <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-content">
                        <form action="${path}/menu/add" class="form-horizontal m-t" id="menuForm" method="post">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">父节点：</label>
                                <div class="col-sm-8">
                                    <input type="hidden" name='pid' value='${pid}'/>
                                    <input type="text" disabled class="form-control" value='${parent.name}'/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">菜单名称：</label>
                                <div class="col-sm-8">
                                    <input type="text" id="name"  name="name" class="form-control" required="">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">菜单标识：</label>
                                <div class="col-sm-8">
                                    <input type="text"   id="identification" name="identification" class="form-control">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">菜单状态：</label>
                                <div class="col-sm-8">
                                     <select class="form-control" id="status" name="status" style="width:100%;">
	                                    <option value="1">启用</option>
	                                    <option value="0">禁用</option>
	                                </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">按钮/菜单：</label>
                                <div class="col-sm-8">
                                    <select class="form-control" id="menuButton" name="menuButton" style="width:100%;">
                                        <option value="menu">菜单</option>
                                        <option value="Button">按钮</option>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">菜单图标：</label>
                                <div class="col-sm-8">
                                    <input type="text"   id="icoUrl"   name="icoUrl" class="form-control">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">菜单排序：</label>
                                <div class="col-sm-8">
                                    <input type="text" id="orderNum" name="orderNum" class="form-control" required="" value="0">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">菜单地址：</label>
                                <div class="col-sm-8">
                                    <input type="text" id="url" name="url" class="form-control" required="">
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-3">
                                    <button class="btn btn-primary" id="add-btn" type="button">添加菜单</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <%@include file="/WEB-INF/common/hplus-js.jsp"%>
    <script src="${path}/assets/hplus/js/demo/form-validate-demo.js"></script>
    <script>
        $(document).ready(function () {
        	$("#menuForm").validate();
            $('.i-checks').iCheck({
                checkboxClass: 'icheckbox_square-green',
                radioClass: 'iradio_square-green',
            });
            $("#add-btn").click(function(){
            	var valid = $("#menuForm").valid();
            	if(valid){
            		$("#menuForm").ajaxSubmit({
                        dataType: "json",
                        success: function (json) {
                            var code = json.code;
                            if(code == 0){
                            	layer.msg('添加成功', {icon: 1});
                                setTimeout(function(){
                                	parent.window.location.reload();
                                	//window.parent.location.reload();
                                	//EventOperation.Refresh("menu-manage");
                                	parent.layer.closeAll();
                                }, 1000);
                            }else{
                            	layer.msg('添加发生错误:' + json.msg, {icon: 5});
                            }
                        },
                        error:function(){
                        	layer.msg('添加发生错误', {icon: 5});
                        }
                    });
            	}else{
            		layer.msg("请填写完整信息！！！！", {
        				icon : 5
        			});
                }
            });
        });
    </script>
</body>
</html>
